package try_codes.p3;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class test {

    public static void main(String[] args) {
        //1.拿到起始时间
        LocalDate startDate=LocalDate.of(2022,2,3);
        //2.获取输入的日期,找到截至日期,转化为日期类型
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入查询年月");
        String stringDate=scanner.next()+"-01";
        LocalDate date = LocalDate.parse(stringDate);
        System.out.println(date);
        LocalDate endDate = date.plusMonths(1).minusDays(1);
        //3.遍历日期,找到当前月份休息的时间
        List<LocalDate> localDates=new ArrayList<>();
        while (startDate.isBefore(endDate)){
                LocalDate relaxDay = startDate.plusDays(3);
                if (relaxDay.isBefore(endDate)&&relaxDay.getMonth().equals(endDate.getMonth())){
                    localDates.add(relaxDay);
                }
                startDate=relaxDay;
        }
        //4.判断集合中那些是周末
        for (LocalDate localDate : localDates) {
            System.out.print(localDate);
            if (localDate.getDayOfWeek().getValue()==6 ){
                System.out.print("(周六)  ");
            }else if (localDate.getDayOfWeek().getValue()==7){
                System.out.print("(周天)  ");
            }
        }
    }


}
